﻿using INTEX.DataBase;
using INTEX.DataBase.Tools;
using ReflectionStudio.Core;
using ReflectionStudio.Core.Events;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.OracleClient;
using System.IO;
using System.Linq;
using System.Windows;
namespace WPFExcelReport
{
    public partial class ITXEXRPT
    {
        public void JLTCOWSLIST(DataSet db)
        {
            int x = 5, y = 1;
            string VKPPOSTYP = "";
            DataTable dtOutput = new DataTable();
            try
            {
                
                int row = 4;
                int idx = 1;
                exAgent.SetCellValue(row, idx++, "ID"); dtOutput.Columns.Add("ROWNID", typeof(System.String));
                exAgent.SetCellValue(row, idx++, "来单日期"); dtOutput.Columns.Add("VKPNEUDAT", typeof(System.String));
                exAgent.SetCellValue(row, idx++, "产品任务号"); dtOutput.Columns.Add("VKPART", typeof(System.String));
                exAgent.SetCellValue(row, idx++, "产品名称"); dtOutput.Columns.Add("VAABEZ", typeof(System.String));//GB2312
                exAgent.SetCellValue(row, idx++, "产品规格"); dtOutput.Columns.Add("CONSTRUCTION", typeof(System.String));//GB2312
                exAgent.SetCellValue(row, idx++, "经密"); dtOutput.Columns.Add("USD2RMB", typeof(System.String));//ADD
                exAgent.SetCellValue(row, idx++, "纬密"); dtOutput.Columns.Add("MVKWEFTDEN", typeof(System.String));
                exAgent.SetCellValue(row, idx++, "纬密总额"); dtOutput.Columns.Add("MCOSTF", typeof(System.String));
                exAgent.SetCellValue(row, idx++, "数量"); dtOutput.Columns.Add("VKPQTY", typeof(System.String));//MY
                exAgent.SetCellValue(row, idx++, "单位"); dtOutput.Columns.Add("VKPUNIT", typeof(System.String));//MY
                exAgent.SetCellValue(row, idx++, "染色"); dtOutput.Columns.Add("MCOSTDY", typeof(System.String));
                exAgent.SetCellValue(row, idx++, "整理费"); dtOutput.Columns.Add("MCOSTFIN", typeof(System.String));
                exAgent.SetCellValue(row, idx++, "运费包装"); dtOutput.Columns.Add("VKCOM", typeof(System.String));
                exAgent.SetCellValue(row, idx++, "接单成本"); dtOutput.Columns.Add("MCOSTPAK", typeof(System.String));
                exAgent.SetCellValue(row, idx++, "制造费"); dtOutput.Columns.Add("MCOSTPROD", typeof(System.String));
                exAgent.SetCellValue(row, idx++, "外销1%成本"); dtOutput.Columns.Add("MCOSTFADD", typeof(System.String));//其他
                exAgent.SetCellValue(row, idx++, "期间费用"); dtOutput.Columns.Add("MCOSTADD", typeof(System.String));//
                exAgent.SetCellValue(row, idx++, "单位产品成本"); dtOutput.Columns.Add("MVKCOST", typeof(System.String));
                exAgent.SetCellValue(row, idx++, "销售价(不含税)"); dtOutput.Columns.Add("MCPRICE", typeof(System.String));
                exAgent.SetCellValue(row, idx++, "货币"); dtOutput.Columns.Add("CURRENCY", typeof(System.String));
                exAgent.SetCellValue(row, idx++, "单位"); dtOutput.Columns.Add("PREH", typeof(System.String));
                exAgent.SetCellValue(row, idx++, "总成本"); dtOutput.Columns.Add("MCOSTDW", typeof(System.String));
                exAgent.SetCellValue(row, idx++, "销售收入"); dtOutput.Columns.Add("MCOSTDF", typeof(System.String));
                exAgent.SetCellValue(row, idx++, "接单工交"); dtOutput.Columns.Add("MCOSTGROSS", typeof(System.String));
                exAgent.SetCellValue(row, idx++, "接单工交总额"); dtOutput.Columns.Add("MCOSTSHIP", typeof(System.String));
                exAgent.SetCellValue(row, idx++, "接单万纬工交"); dtOutput.Columns.Add("MCOSTNETW", typeof(System.String));
                exAgent.SetCellValue(row, idx++, "实际工交"); dtOutput.Columns.Add("MCOSTFVV", typeof(System.String));
                exAgent.SetCellValue(row, idx++, "实际工总额"); dtOutput.Columns.Add("MUNITSHIP", typeof(System.String));
                exAgent.SetCellValue(row, idx++, "实际万纬工交"); dtOutput.Columns.Add("MCSOTU", typeof(System.String));
                exAgent.SetCellValue(row, idx++, "客户"); dtOutput.Columns.Add("KDKUNDNA", typeof(System.String));
                exAgent.SetCellValue(row, idx++, "总原料费"); dtOutput.Columns.Add("MPRICEAGENT", typeof(System.String));
                exAgent.SetCellValue(row, idx++, "总染色费"); dtOutput.Columns.Add("MUNITAGENT", typeof(System.String));
                exAgent.SetCellValue(row, idx++, "总整理费"); dtOutput.Columns.Add("MPRICESHIP", typeof(System.String));
                 
                exAgent.SetCurrentSheet("JLTCOWSLIST");
                exAgent.RenameSheet(date); 
                dtOutput.Merge(db.Tables["ICC_VKPRICE"], false, MissingSchemaAction.Ignore); 
                int count = dtOutput.Rows.Count;
                exAgent.RangeCopy(5, 5, 6, 6 + count);
                exAgent.DataTableToExcel(dtOutput, x, 1); 
                exAgent.BatchConvert2Number(4, 4, count + 4, 28);
                exAgent.SetCellValue(1, 1, " ");

            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            finally
            {
                EventDispatcher.Instance.RaiseStatus("完成", StatusEventType.StopProgress);
            }
        }

    }
}